﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

namespace EasyLibrary.AR.Classes
{
    public class Pais
    {
        public Pais()
        {
            IdPais = -1;
            Desc_pais = string.Empty;
            Gm_pais = string.Empty;
            Gm_distritos = string.Empty;
            Gm_latcenter = -1;
            Gm_lngcenter = -1;
            Gm_zoom = 1;
            ListUtilizador = null;
        }

        public int IdPais { get; set; }

        public string Desc_pais { get; set; }

        public string Gm_pais { get; set; }

        public string Gm_distritos { get; set; }

        public float Gm_latcenter { get; set; }

        public float Gm_lngcenter { get; set; }

        public int Gm_zoom { get; set; }

        public List<Utilizador> ListUtilizador { get; set; }


        public List<Pais> GetPais()
        {
            var Sqlconn = new SqlConnection(ConnectionString.GetUsingHostname());

            try
            {
                var mylist = new List<Pais>(); // PaisDB.GetPais(ref Sqlconn);

                return mylist;
            }

            catch (SqlException ex)
            {
                string str = "Source:" + ex.Source;
                str += "\n" + "Exception Message:" + ex.Message;
                Console.WriteLine(str);

                throw new Exception("Erro de SQL: " + str + "");
            }
            finally
            {
                if (Sqlconn.State == ConnectionState.Open)
                    Sqlconn.Close();
            }
        }

        public Pais GetPaisbyId(int id)
        {
            var Sqlconn = new SqlConnection(ConnectionString.GetUsingHostname());

            try
            {
                return null;
                // (PaisDB.GetPaisbyId(ref Sqlconn, id));
            }

            catch (SqlException ex)
            {
                string str = "Source:" + ex.Source;
                str += "\n" + "Exception Message:" + ex.Message;
                Console.WriteLine(str);

                throw new Exception("Erro de SQL: " + str + "");
            }
            finally
            {
                if (Sqlconn.State == ConnectionState.Open)
                    Sqlconn.Close();
            }
        }
    }
}